#!/bin/bash  
  
# 获取所有的提交ID  
commit_ids=$(git log --pretty=format:"%H" | tr '\n' ' ')  
  
# 初始化计数器  
line_count=0  
  
# 遍历每一个提交ID  
for commit_id in $commit_ids; do  
    # 获取该提交修改的文件列表  
    files=$(git show --pretty="" --name-only $commit_id)  
  
    # 遍历每一个文件  
    for file in $files; do  
        # 使用git diff统计修改的行数，并累加到line_count中  
        line_count=$((line_count + $(git diff --shortstat $commit_id^! -- $file | awk '/^ [0-9]+ files changed, [0-9]+ insertions\(\+\), [0-9]+ deletions\(-\)/ {print $3 + $6}')))  
    done  
done  
  
# 输出结果  
echo "Total lines changed: $line_count"
